<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript" src="js/jquery-1.11.0.js" ></script>
		<script>
			$(function(){
				$.getScript("js/city.js",function(data){
					var result=JSON.parse(data);
					var cityArray=[];
					var countArray=[];
					for(var i=0;i<result.length;i++)
					{
						if(result[i].ProSort)
						{
							$(".provice").append("<option value='"+result[i].ProID+"'>"+result[i].name+"</option>")
						}else if(result[i].CitySort)
						{
							cityArray.push(result[i]);
						}else if(result[i].DisSort==null)
						{
							countArray.push(result[i]);
						}
					}
					$(".provice").change(function(){
						var value=$(this).val();
						console.log(value);
						$(".city option:gt(0)").remove();
						$(".county option:gt(0)").remove();
						for(var i=0;i<cityArray.length;i++)
						{
							if(cityArray[i].ProID==value)
							{
								$(".city").append("<option value='"+cityArray[i].CityID+"'>"+cityArray[i].name+"</option>");
							}
						}
					})
					
					$(".city").change(function(){
						var value=$(this).val();
						$(".county option:gt(0)").remove();
						for(var i=0;i<countArray.length;i++)
						{
							if(countArray[i].CityID==value)
							{
								$(".county").append("<option value='"+countArray[i].Id+"'>"+countArray[i].DisName+"</option>");
							}
							
						}
					})
				})
			})	
		</script>
	</head>
	<body>
		<select class="provice">
			<option>请选择省份</option>
		</select>
		<select class="city">
			<option>请选择市区</option>
		</select>
		<select class="county">
			<option>请选择县区</option>
		</select>
	</body>
</html>
